package com.mic.yzzn.plc.core.control.handler;

import com.mic.yzzn.plc.core.control.datastructure.COMStationConfig;
import com.mic.yzzn.plc.core.control.datastructure.PLCStationConfig;
import com.mic.yzzn.plc.core.control.datastructure.TCPStationConfig;

/**
 * Created by ASH on 16/7/18.
 *
 * Handler 工厂
 */
public class HandlerFactory {
    public static PLCMissionHandler handler(PLCStationConfig stationConfig) throws Exception {
        if (stationConfig.getClass() == TCPStationConfig.class) {
            TCPMissionHandler handler = new TCPMissionHandler();
            handler.setStationConfig(stationConfig);
            return handler;
        } else if (stationConfig.getClass() == COMStationConfig.class) {
            COMMissionHandler handler =  new COMMissionHandler();
            handler.setStationConfig(stationConfig);
            return handler;
        } else {
            return null;
        }
    }
}
